package o;

import com.huawei.appgallery.forum.message.api.IUpdatePushResult;
import com.huawei.appgallery.forum.message.msgsetting.launcher.LauncherMsgSettingManager$2$1;
import com.huawei.appgallery.forum.message.msgsetting.launcher.LauncherMsgSettingManager$2$2;
import com.huawei.appgallery.forum.message.msgsetting.launcher.request.UploadPushTokenResponse;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.fastengine.fastview.download.utils.PackageUtils;
import o.brc.e;
import o.bwa.d;

public class bwc {
    public void ˎ(int i, boolean z, e eVar) {
        bwj o_bwj = new bwj();
        o_bwj.ॱ(i, z);
        ((brc) fho.ˏ().ˋ("Base").ॱ(brc.class)).ˋ(o_bwj, eVar);
    }

    public void ˋ(boolean z, String str, final int i, final fjx<IUpdatePushResult> o_fjx_com_huawei_appgallery_forum_message_api_IUpdatePushResult) {
        if (UserSession.getInstance().isLoginSuccessful()) {
            bwo o_bwo = new bwo();
            o_bwo.ˋ(z ? 1 : 0);
            o_bwo.ˎ(i);
            if (cgy.ˎ(str)) {
                bqx.ˊ("LauncherMsgSettingManager", "uploadPushToken pushToken error null, need getTokenAsyn.");
                ॱ(z, i, o_fjx_com_huawei_appgallery_forum_message_api_IUpdatePushResult);
                return;
            }
            o_bwo.ˋ(str);
            ((brc) fho.ˏ().ˋ("Base").ॱ(brc.class)).ˋ(o_bwo, new e<bwo, UploadPushTokenResponse>(this) {
                final /* synthetic */ bwc ˋ;

                public /* synthetic */ void ˏ(Object obj, Object obj2) {
                    ॱ((bwo) obj, (UploadPushTokenResponse) obj2);
                }

                public void ॱ(bwo o_bwo, UploadPushTokenResponse uploadPushTokenResponse) {
                }

                public void ˋ(bwo o_bwo, UploadPushTokenResponse uploadPushTokenResponse) {
                    boolean z = true;
                    bwg.ॱ(true);
                    if (o_fjx_com_huawei_appgallery_forum_message_api_IUpdatePushResult == null) {
                        return;
                    }
                    if (uploadPushTokenResponse.getResponseCode() == 0 && uploadPushTokenResponse.getRtnCode_() == 0) {
                        if (i == 0) {
                            if (uploadPushTokenResponse.ˎ() != 1) {
                                z = false;
                            }
                            if (z != euf.ˎ().ˏ()) {
                                bqx.ˊ("LauncherMsgSettingManager", "push status change from server");
                                bwg.ॱ(z);
                            }
                        }
                        o_fjx_com_huawei_appgallery_forum_message_api_IUpdatePushResult.ॱ(new LauncherMsgSettingManager$2$1(this, uploadPushTokenResponse));
                        return;
                    }
                    o_fjx_com_huawei_appgallery_forum_message_api_IUpdatePushResult.ॱ(new LauncherMsgSettingManager$2$2(this, uploadPushTokenResponse));
                }
            });
            return;
        }
        bqx.ˏ("LauncherMsgSettingManager", "unlogin ,do not upload.");
    }

    private void ॱ(boolean z, int i, fjx<IUpdatePushResult> o_fjx_com_huawei_appgallery_forum_message_api_IUpdatePushResult) {
        fhz ˋ = fho.ˏ().ˋ("Push");
        if (ˋ != null) {
            cuc o_cuc = (cuc) ˋ.ॱ(cuc.class);
            if (o_cuc != null) {
                o_cuc.ˏ(bwa.class);
            }
        }
        d dVar = new d();
        dVar.ˏ(z);
        dVar.ˋ(i);
        dVar.ˏ((fjx) o_fjx_com_huawei_appgallery_forum_message_api_IUpdatePushResult);
        bwa.ˊ(dVar);
        new cuh().ˏ();
    }

    public void ˋ(int i) {
        if (!PackageUtils.HWGAMEBOX_PACKAGE_NAME.equals(bqy.ˋ().ˏ().getPackageName())) {
            return;
        }
        if (i == 1) {
            if (bwd.ˎ()) {
                bwd.ॱ(0);
            }
        } else if (i == 0) {
            bqx.ˊ("LauncherMsgSettingManager", "user login ,uploadPushToken");
            ˋ(euf.ˎ().ˏ(), epr.ˎ().ॱˊ(), 0, null);
        }
    }
}
